<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button {
            width: 60px;
            height: 40px;
            cursor: pointer;
            border: 0;
            border-radius: 4px;
        }

        .pink {
            background-color: pink;
        }

        .skyblue {
            background-color: skyblue;
        }
    </style>
</head>

<body>

    <button class="pink" id="bthPink"></button>
    <button class="skyblue" id="bthSkyblue"></button>
    <script>
        // 改变网页背景色
        document.getElementById('bthPink').onclick = function () {
            document.body.style.backgroundColor = 'pink';
        };

        var btn = document.getElementById('bthSkyblue');
        btn.onclick = function () {
            document.body.style.backgroundColor = 'skyblue';
        }

        // 验证用户输入的密码
        var a = prompt('请输入登录密码(6)');
        if (a == 6) {
            alert('密码输入正确！');
        }
        else {
            alert('密码输入错误！');
        }

        // 计算年龄小游戏
        var a = prompt('请输入你的出生年份');
        if (parseInt(a) == a) {
            a = 2022 - a;
            alert('你的年龄为: ' + a);
        }
        else {
            alert('请输入正确的年份！');
        }


    </script>
</body>

</html>